package com.jpragma.logviewer.util {
	import mx.controls.DataGrid;
	import mx.controls.Label;
	import mx.controls.dataGridClasses.DataGridListData;
	
	public class LogMessageDatagridItemRenderer extends Label {
		
		private static var levelColors:Object = {
			"FATAL": 0xFF0000,
			"ERROR": 0xFF0000,
			"WARN": 0x9900CC,
			"INFO": 0x009900,
			"DEBUG": 0x000099,
			"TRACE": 0x000000};
			
		
		override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void {
			super.updateDisplayList(unscaledWidth, unscaledHeight);
			var grid:DataGrid = DataGrid(DataGridListData(listData).owner);
			if (!grid.isItemSelected(data) && !grid.isItemHighlighted(data)) {
				var level:String = data["level"];
				var color:int = levelColors[level];
				this.setStyle("color", color);
			}
		}		
	}
}